export default {
	//切换市
	cityChooseItem(item,index){
		this.cityCurrent = index
		this.cityId = item.city_id
		this.areaCurrent = -1
		this.getArea(item.city_id)
		wx.vibrateShort()
	},
	//切换区
	areaChooseItem(item,index){
		this.$toast.confirm({
			content: '确认将城市切换为'+ item.name+'吗？',
			confirmText: '确定',
			callback: result => {
				if (result) {
					this.areaCurrent = index
					this.countyId = item.county_id
					this.countyName = item.name
				}else{
					
				}
			}
		})
		
		wx.vibrateShort()
	},
	// 获取所有城市
	getCity() {
		let that = this
		that.$httpRequest.request({
			that: that,
			url: 'publics/getAllCity',
			params: {
				
			},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.cityList = res.data
					that.cityId = res.data[0].city_id
					that.getArea(res.data[0].city_id)
					
				}
			}
		})
	},
	// 获取所有区
	getArea(id) {
		let that = this
		that.$httpRequest.request({
			that: that,
			url: 'publics/getCounty',
			params: {
				city_id:id
			},
			success: res => {
				if (res.code === that.$httpConfig.SUCCESS_CODE) {
					that.areaList = res.data
					
				}
			}
		})
	},
}